package com.example.demo.controller;

import com.example.demo.entity.LcdInfo;
import com.example.demo.entity.TvInfo;
import com.example.demo.service.LcdInfoService;
import com.example.demo.service.TvInfoService;
import com.example.demo.util.GetMessage;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.RequiredArgsConstructor;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/lcd")
@RequiredArgsConstructor
@Component
public class LcdInfoController {
    private final LcdInfoService lcdInfoService;
    @CrossOrigin(origins ="*" ,maxAge = 3600)
    @GetMapping("/select")
    public GetMessage select () throws JsonProcessingException, MqttException {
        List<LcdInfo> list=lcdInfoService.selcet();

        return new GetMessage("成功","200",list);

    }
    @CrossOrigin(origins ="*" ,maxAge = 3600)
    @GetMapping("/selectbymodel")
    public GetMessage selectbymodel (String productModel) throws JsonProcessingException, MqttException {
        LcdInfo list=lcdInfoService.selectbymodel(productModel);

        return new GetMessage("成功","200",list);

    }
}
